<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="時光的个人博客" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
	  <meta name="referrer" content="no-referrer" />

      <title>Docker部署去中心化聊天室 |  時光</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="時光" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-Docker部署去中心化聊天室"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Docker部署去中心化聊天室
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/12/16/Docker%E9%83%A8%E7%BD%B2%E5%8E%BB%E4%B8%AD%E5%BF%83%E5%8C%96%E8%81%8A%E5%A4%A9%E5%AE%A4/" class="article-date">
  <time datetime="2023-12-16T02:37:22.325Z" itemprop="datePublished">2023-12-16</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.1k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">4 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="一、项目介绍"><a href="#一、项目介绍" class="headerlink" title="一、项目介绍"></a>一、项目介绍</h1><p>需要搭建 <code>Matrix</code> 服务和 <code>Element</code> Web端应用</p>
<p>Matrix 是一个开放的通信协议，用于实时通信，包括即时消息、音频和视频通话。<br>它是去中心化的，这意味着任何人都可以设置自己的 Matrix 服务器，并与其他 Matrix 服务器通信。<br>Matrix 的目标是为所有不同的通信服务提供一个统一的标准，使得不同的服务可以互相通信。</p>
<p>Element 是基于 Matrix 协议的一个客户端应用。<br>它允许用户通过 Matrix 协议进行即时消息、音频和视频通话。<br>Element 有多个版本，包括 Web、桌面和移动应用。<br>它是 Matrix 生态系统中最流行的客户端之一。</p>
<p>Matrix 官方网站：<a target="_blank" rel="noopener" href="https://matrix.org/">https://matrix.org/</a><br>Matrix GitHub 官方仓库：<a target="_blank" rel="noopener" href="https://github.com/matrix-org/synapse">https://github.com/matrix-org/synapse</a><br>Element 官方网站：<a target="_blank" rel="noopener" href="https://element.io/">https://element.io/</a><br>Element 自建 GitHub 地址：<a target="_blank" rel="noopener" href="https://github.com/vector-im/element-web">https://github.com/vector-im/element-web</a></p>
<h1 id="二、安装步骤"><a href="#二、安装步骤" class="headerlink" title="二、安装步骤"></a>二、安装步骤</h1><h2 id="1、绑定域名"><a href="#1、绑定域名" class="headerlink" title="1、绑定域名"></a>1、绑定域名</h2><p>需要分别为 <code>Matrix</code> 和 <code>Element</code> 绑定域名，各添加一条A记录</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216103438808-1079332897.png" alt="image-20231216103439701"></p>
<h2 id="2、添加反向代理"><a href="#2、添加反向代理" class="headerlink" title="2、添加反向代理"></a>2、添加反向代理</h2><p>使用 <code>Nginx Proxy Manager</code> 添加反向代理，我分别使用8008和8009端口，注意开放相应防火请</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216104142659-1351285830.png" alt="image-20231216104143585"></p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216104034892-860427198.png" alt="image-20231216104035864"></p>
<p>可以再设置一下SSL</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216104304537-911226898.png" alt="image-20231216104305597"></p>
<h2 id="3、部署服务"><a href="#3、部署服务" class="headerlink" title="3、部署服务"></a>3、部署服务</h2><p>创建目录</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> -p /root/docker_data/matrix</span><br><span class="line"></span><br><span class="line"><span class="built_in">cd</span> /root/docker_data/matrix</span><br></pre></td></tr></table></figure>

<p>拉取并运行镜像，注意修改 <code>SYNAPSE_SERVER_NAME</code> 为自己刚才设置的matrix需绑定的域名</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo docker run -it --<span class="built_in">rm</span> \</span><br><span class="line">-v /root/docker_data/matrix/data:/data \</span><br><span class="line">-e SYNAPSE_SERVER_NAME=matrix.shiguangdev.eu.org \</span><br><span class="line">-e SYNAPSE_REPORT_STATS=<span class="built_in">yes</span> \</span><br><span class="line">matrixdotorg/synapse:latest generate</span><br></pre></td></tr></table></figure>

<p>修改 <code>homeserver.yaml</code> 文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /root/docker_data/matrix/data</span><br><span class="line"></span><br><span class="line">vim homeserver.yaml</span><br></pre></td></tr></table></figure>

<p>在最底部添加以下内容，打开注册功能以及跳过注册验证</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">enable_registration: true</span><br><span class="line">enable_registration_without_verification: true</span><br></pre></td></tr></table></figure>

<p>如图所示</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216111206506-1747171155.png" alt="image-20231216111207502"></p>
<p>创建 <code>docker-compose.yml</code> 文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /root/docker_data/matrix</span><br><span class="line">vim docker-compose.yml</span><br></pre></td></tr></table></figure>

<p>粘贴以下内容，注意将 <code>VIRTUAL_HOST</code>、<code>LETSENCRYPT_HOST</code>、<code>SYNAPSE_SERVER_NAME</code> 替换为自己的域名</p>
<p>如端口需调整，注意修改</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">version: &quot;3.3&quot;</span><br><span class="line"></span><br><span class="line">services:</span><br><span class="line">  synapse:</span><br><span class="line">    image: &quot;matrixdotorg/synapse:latest&quot;</span><br><span class="line">    container_name: &quot;matrix_synapse&quot;</span><br><span class="line">    restart: unless-stopped</span><br><span class="line">    ports:</span><br><span class="line">      - 8008:8008</span><br><span class="line">    volumes:</span><br><span class="line">      - &quot;./data:/data&quot; # it will look at the current directory where you save the file and look for the data folder inside</span><br><span class="line">    environment:</span><br><span class="line">      VIRTUAL_HOST: &quot;matrix.shiguangdev.eu.org&quot;</span><br><span class="line">      VIRTUAL_PORT: 8008</span><br><span class="line">      LETSENCRYPT_HOST: &quot;matrix.shiguangdev.eu.org&quot;</span><br><span class="line">      SYNAPSE_SERVER_NAME: &quot;matrix.shiguangdev.eu.org&quot;</span><br><span class="line">      SYNAPSE_REPORT_STATS: &quot;yes&quot;</span><br><span class="line">  element-web:</span><br><span class="line">    ports:</span><br><span class="line">      - &#x27;8009:80&#x27;</span><br><span class="line">    #volumes:</span><br><span class="line">    #    - &#x27;/etc/element-web/config.json:/app/config.json&#x27;</span><br><span class="line">    image: vectorim/element-web</span><br><span class="line">    restart: unless-stopped</span><br></pre></td></tr></table></figure>

<p>执行 <code>docker-compose up -d</code> </p>
<p>通过 ip+端口 或者域名即可访问 </p>
<p>Matrix服务</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216111939375-1481886112.png" alt="image-20231216111940434"></p>
<p>Element</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216112512215-782901218.png" alt="image-20231216112511645"></p>
<p>若出现以下错误，需用域名访问，并且使用https的方式访问，反向代理时，SSL可勾选 <code>Force SSL</code> 强制https访问</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216115241484-1378905479.png" alt="image-20231216115239099"></p>
<h2 id="4、注册账号与使用"><a href="#4、注册账号与使用" class="headerlink" title="4、注册账号与使用"></a>4、注册账号与使用</h2><h3 id="4-1-注册账号"><a href="#4-1-注册账号" class="headerlink" title="4.1 注册账号"></a>4.1 注册账号</h3><p>可以调整语言为简体中文</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216113645928-1507737593.png" alt="image-20231216113640915"></p>
<p>创建账户 &#x3D;&gt; 编辑 &#x3D;&gt; 使用自己搭建的Matrix服务</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216113818269-1292002415.png" alt="image-20231216113802377"></p>
<p>设置用户名及密码</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216114010475-1037490128.png" alt="image-20231216113954180"></p>
<p>这个界面可以跳过</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216114312568-40872563.png" alt="image-20231216114256868"></p>
<p>至此账号已经创建完成</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216114356300-1469636097.png" alt="image-20231216114342244"></p>
<p>点击头像可以查看账户地址</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120229818-1549433554.png" alt="image-20231216120215840"></p>
<p>或者在所有设置 &#x3D;&gt; 通用 &#x3D;&gt; 个人资料查看</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120422432-324325353.png" alt="image-20231216120419789"></p>
<h3 id="4-2-日常对话"><a href="#4-2-日常对话" class="headerlink" title="4.2 日常对话"></a>4.2 日常对话</h3><p>新创建跟个账户模拟聊天，输入对方账户地址，前往</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120603180-1034483934.png" alt="image-20231216120549415"></p>
<p>模拟向对方发送一条消息</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120700131-163692231.png" alt="image-20231216120646646"></p>
<p>对方会收到邀请通知</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120819274-1229705909.png" alt="image-20231216120805384"></p>
<p>对方可以接受聊天或者拒绝</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216120859680-348034285.png" alt="image-20231216120846117"></p>
<p>回复一条消息</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216121012437-1912795107.png" alt="image-20231216120958779"></p>
<p>你接收到的消息</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216121127847-1783790803.png" alt="image-20231216121114678"></p>
<h3 id="4-3-房间及视频通话"><a href="#4-3-房间及视频通话" class="headerlink" title="4.3 房间及视频通话"></a>4.3 房间及视频通话</h3><p>可以创建房间，类似群的功能</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216121442571-156016793.png" alt="image-20231216121439987"></p>
<p>如果需要视频通话，可以在设置 &#x3D;&gt; 实验室 &#x3D;&gt; 加入beta</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216121637081-433229662.png" alt="image-20231216121623465"></p>
<p>加入beta 后就可以创建视频房间了</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216121820516-93927935.png" alt="image-20231216121807060"></p>
<p>模拟创建一个视频房间</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216122138940-140971214.png" alt="image-20231216122131578"></p>
<p>要求成员加入，被要求人也需加入beta</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216122138480-1948953704.png" alt="image-20231216122125001"></p>
<p>被邀请人加入beta后可接受要求</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216122218181-1818224132.png" alt="image-20231216122205067"></p>
<p>开启视频和麦克风权限后就能开启视频通话了</p>
<p><img src="https://img2023.cnblogs.com/blog/2233039/202312/2233039-20231216122355789-854176605.png" alt="image-20231216122342282"></p>
<h2 id="5、更新服务"><a href="#5、更新服务" class="headerlink" title="5、更新服务"></a>5、更新服务</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /root/docker_data/matrix</span><br><span class="line"></span><br><span class="line">docker-compose pull</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> <span class="comment"># 请不要使用 docker-compose stop 来停止容器，因为这么做需要额外的时间等待容器停止</span></span><br><span class="line"> <span class="comment"># docker-compose up -d 直接升级容器时会自动停止并立刻重建新的容器,可以节省一些时间</span></span><br><span class="line">docker-compose up -d   </span><br><span class="line"></span><br><span class="line"><span class="comment"># prune 命令用来删除不再使用的 docker 对象。删除所有未被 tag 标记和未被容器使用的镜像</span></span><br><span class="line">docker image prune  </span><br></pre></td></tr></table></figure>

<h2 id="6、卸载服务"><a href="#6、卸载服务" class="headerlink" title="6、卸载服务"></a>6、卸载服务</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /root/docker_data/matrix</span><br><span class="line"></span><br><span class="line">docker-compose down</span><br><span class="line"></span><br><span class="line"><span class="built_in">cd</span> ..</span><br><span class="line"></span><br><span class="line"><span class="built_in">rm</span> -rf /root/docker_data/matrix  <span class="comment"># 完全删除</span></span><br></pre></td></tr></table></figure>



<p><strong>参考文章</strong></p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.laoda.de/archives/docker-compose-install-matrix-element/">https://blog.laoda.de/archives/docker-compose-install-matrix-element/</a></p>
</blockquote>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          Donate
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2023/12/16/Docker%E9%83%A8%E7%BD%B2%E5%8E%BB%E4%B8%AD%E5%BF%83%E5%8C%96%E8%81%8A%E5%A4%A9%E5%AE%A4/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Docker/" rel="tag">Docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Element/" rel="tag">Element</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Maxtri/" rel="tag">Maxtri</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2023/12/16/Docker%E6%90%AD%E5%BB%BA%E5%93%AA%E5%90%92%E9%9D%A2%E6%9D%BF/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Docker搭建哪吒面板
          
        </div>
      </a>
    
    
      <a href="/2023/12/13/Docker%E9%83%A8%E7%BD%B2ChatBotUI/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">Docker部署ChatBotUI</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.staticfile.org/valine/1.4.16/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "dx3B54wOwhi75vxC2IAZagtg-gzGzoHsz",
    app_key: "m4k2fhnFa1iPI4vbofHqMY5X",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
  
   
    <script src="https://cdn.staticfile.org/twikoo/1.4.18/twikoo.all.min.js"></script>
    <div id="twikoo" class="twikoo"></div>
    <script>
        twikoo.init({
            envId: ""
        })
    </script>
 
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023
        <i class="ri-heart-fill heart_icon"></i> Shiguang
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="時光"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>